package com.lagou.edu.boss.rest;

import com.lagou.edu.ad.api.AdRemoteService;
import com.lagou.edu.common.entity.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/ad")
public class AdController {

    @Autowired
    private AdRemoteService adRemoteService;

    /**
     * 查询指定广告定位信息
     * @return
     */
    @GetMapping("/space/getOneSpace")
    @ResponseBody
    public Result getOneSpace(@RequestParam("id") String id) {
        return Result.success(adRemoteService.getAdById(Integer.parseInt(id)));
    }

    /**
     * 查询所有广告定位信息列表
     * @return
     */
    @GetMapping("/space/getAllSpaces")
    @ResponseBody
    public Result getAllSpace() {
        return Result.success(adRemoteService.getAllSpaces());
    }

    /**
     * 通过SpaceKey列表查询所有广告信息列表
     * @return
     */
    @GetMapping("/getAllAd")
    @ResponseBody
    public Result getAllPromotionAdsBySpaceKey(@RequestParam("ids") String ids) {
        //return Result.success(adRemoteService.getAllAds());
        return null;
    }


    /**
     * 通过SpaceKey列表获取广告位以及对应的广告信息
     * @return
     */
    @GetMapping("/getAllAds")
    @ResponseBody
    public Result getAllPromotionAds(@RequestParam("spaceKeys") String[] spaceKeys) {

        return Result.success(adRemoteService.getAllAds(spaceKeys));
    }


}
